﻿package cn.edu.zjusc.Webservice;

import java.util.List;

import javax.ejb.Stateless;
import javax.jws.*;
import javax.jws.soap.SOAPBinding;

import org.jboss.wsf.spi.annotation.WebContext;

import cn.edu.zjusc.POJO.*;
import cn.edu.zjusc.Util.PersistenceHelper;

@Stateless
@WebService(name = "LogService", serviceName = "LogService")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@WebContext(contextRoot = "/ZJUSCIX/Service", urlPattern = "/LogService")
public class LogService {

	/**
	 * 获得所有日志
	 * 
	 * @return
	 */
	@SuppressWarnings({ "unchecked" })
	public List<LogInfo> GetAllLogInfo() {

		String hql = "from LogInfo e";
		return PersistenceHelper.executeReader(hql);
	}

	/**
	 * 获得某种类型的日志
	 * 
	 * @param type
	 * @return
	 */
	@SuppressWarnings({ "unchecked" })
	public List<LogInfo> GetLogInfoByType(@WebParam(name = "typeID") String type) {

		String hql = "from LogInfo e where e.type=?1";
		Object[] params = { type };
		return PersistenceHelper.executeReader(hql, params);
	}

	/**
	 * 删除日志
	 * 
	 * @param logID
	 * @return
	 */
	public String DeleteLogInfo(@WebParam(name = "id") int logID) {

		PersistenceHelper.deleteEntity(LogInfo.class, logID);
		return "删除日志成功";
	}
}
